package com.zhuimeng.monitor;

import com.zhuimeng.monitor.bean.MethodInfo;

import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class RemoveDataThread implements Runnable{
    Map<String, List<MethodInfo>> methodTime;

    public RemoveDataThread(Map<String, List<MethodInfo>> methodTime) {
        this.methodTime = methodTime;
    }

    @Override
    public void run() {
        for (Map.Entry<String, List<MethodInfo>> methodInfos : methodTime.entrySet()) {
            List<MethodInfo> methodInfoList = methodInfos.getValue();
            Iterator<MethodInfo> iterator = methodInfoList.iterator();
            long removeCon = System.currentTimeMillis()-60000;
            while (iterator.hasNext()){
                MethodInfo methodInfo = iterator.next();
                if (methodInfo.getEndTime()<removeCon){
                    iterator.remove();
                }
            }
        }

    }
}
